<?php

namespace app\admin\model\xyvenue;

use think\Model;


class Air extends Model
{

    

    

    // 表名
    protected $name = 'xyvenue_air';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'switch_text',
        'mode_text'
    ];
    

    
    public function getSwitchList()
    {
        return ['on' => __('On'), 'off' => __('Off')];
    }

    public function getModeList()
    {
        return ['auto' => __('Auto'), 'cool' => __('Cool'), 'dry' => __('Dry'), 'fan' => __('Fan'), 'heat' => __('Heat')];
    }


    public function getSwitchTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['switch']) ? $data['switch'] : '');
        $list = $this->getSwitchList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getModeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['mode']) ? $data['mode'] : '');
        $list = $this->getModeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
